package com.itheima.dao;


import com.github.pagehelper.Page;
import com.itheima.pojo.CheckItem;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;


//检查项mapper服务
public interface CheckItemDao {

    @Insert("insert into t_checkitem(code,name,sex,age,price,type,remark,attention) values (#{code},#{name},#{sex},#{age},#{price},#{type},#{remark},#{attention})")
    public void  add(CheckItem checkItem);

    //    分页查询
    public Page<CheckItem> selectByCondition(String queryString);

    //删除检查项
    @Update("delete from t_checkitem where id = #{id}")
    public void  del(Integer id);

    //查询是否关联检查组
    @Select("select count(*) from t_checkgroup_checkitem where checkitem_id = #{checkitem_id}")
    public long findCountByCheckItemId(Integer checkitemid);


    //回写数据
    @Select("select * from t_checkitem where id = #{id}")
    public CheckItem  FindAll(Integer id);

//    编辑检查项
    public void  edit(CheckItem checkItem);

//    查询所有检查项数据
    @Select("select * from t_checkitem")
    List<CheckItem> findallitem();


    @Select("SELECT  * FROM t_checkitem WHERE id IN(SELECT checkitem_id FROM t_checkgroup_checkitem WHERE checkgroup_id=#{checkgroup_id})")
    List<CheckItem> findcheckItemId(int checkgroup_id);
}
